<div class="page-header">
    <h1>New vote</h1>
</div>

<% form_for(vote, {action: path_to.votes(), method: 'POST', id: "vote_form", class: 'form-horizontal'}, function (form) { %>
	
    <%- partial('votes/form.ejs', {locals: {form: form, vote: vote}}) %>
    <div class="form-actions">
        <%- form.submit('<i class="icon-ok icon-white"></i> Create vote', {class: 'btn btn-primary'}) %> or
        <%- link_to('Cancel', path_to.votes(), {class: 'btn'}) %>
    </div>
    
    <div class="span12">
    <% if(votes.length > 0){ %>
    	<table class="table table-striped">
                <thead>
                    <tr>
                        <th>name</th>
                        <th>Actions</th>
                    </tr>
                </thead>
                <tbody>
                    <% votes.forEach(function (vote) { %>
                        <tr>
                            <td><strong><%- link_to('vote #' + vote.id, path_to.votes(vote)) %></strong></td>
                            <td>
                                <%- link_to('<i class="icon-edit"></i> Edit', path_to.edit_vote(vote), {class: 'btn btn-mini'}) %>
                                <%- link_to('<i class="icon-remove icon-white"></i> Delete', path_to.vote(vote), {class: 'btn btn-mini btn-danger', method: 'delete', remote: true, jsonp: '(function (u) {location.href = u;})'}) %>        
                            </td>
                        </tr>
                    <% }); %>        
                </tbody>
            </table>
     <% } else { %>
            <p class="alert alert-block alert-info">
                <strong>No votes were found.</strong> 
            </p>
        <% } %>
    </div>
<% });%>
